﻿using System;
using System.Collections.Generic;
using System.Text;
using Velocity4Net.Runtime.Logging;
using Velocity4Net.Runtime.Parse.AST;

namespace Velocity4Net.Util.Introspection
{
    public class Info
    {
        private int line;
        private int column;
        private String templateName;

        /**
         * @param source Usually a template name.
         * @param line The line number from <code>source</code>.
         * @param column The column number from <code>source</code>.
         */
        public Info(String source, int line, int column)
        {
            this.templateName = source;
            this.line = line;
            this.column = column;
        }

        public Info(INode node)
            : this(node.TemplateName, node.Line, node.Column)
        {

        }

        /**
         * Force callers to set the location information.
         */
        private Info()
        {
        }

        /**
         * @return The template name.
         */
        public String getTemplateName()
        {
            return templateName;
        }

        /**
         * @return The line number.
         */
        public int getLine()
        {
            return line;
        }

        /**
         * @return The column number.
         */
        public int getColumn()
        {
            return column;
        }

        /**
         * Formats a textual representation of this object as <code>SOURCE
         * [line X, column Y]</code>.
         *
         * @return String representing this object.
         * @since 1.5
         */
        public override string ToString()
        {
            return Log.formatFileString(getTemplateName(), getLine(), getColumn());
        }
    }
}
